﻿using Class_Entity.ObjectTwo;
using DataAccess.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BussinessObject.ObjectTwo
{
   public class B_Search
    {
       D_Search ex = new D_Search();
       DataTable tb = new DataTable();
       
       public Companies loadCom(int val)
       {
           Companies fx = new Companies();
           tb = ex.loadCompany(val);
           foreach (DataRow dr in tb.Rows)
           {
               fx.COMPANY_CODE = dr["COMPANY_CODE"].ToString();
               fx.COMPANY_NAME = dr["COMPANY_NAME"].ToString();
               fx.COMPANY_PHONE = dr["COMPANY_PHONE"].ToString();
               fx.COMPANY_EMAIL = dr["COMPANY_EMAIL"].ToString();
               fx.DESCRIPTION = dr["DESCRIPTION"].ToString();
               fx.COMPANY_ADDRESS = dr["COMPANY_ADDRESS"].ToString();
           }
           return fx;
       }
       public Cities loadCity(int val)
       {
           Cities gx = new Cities();
           tb = ex.loadCity(val);
           foreach (DataRow dr in tb.Rows)
           {               
               gx.CITY_CODE = dr["CITY_CODE"].ToString();              
               gx.CITY_NAME = dr["CITY_NAME"].ToString();
               gx.DESCRIPTION = dr["DESCRIPTION"].ToString();             
           }
           return gx;
       }
       public CC_Branches loadBran(int val)
       {
           CC_Branches gx = new CC_Branches();
           tb = ex.loadBran(val);
           int tam = tb.Rows.Count;
           int a = tam;
           foreach (DataRow dr in tb.Rows)
           {
               gx.BRANCH_CODE = dr["BRANCH_CODE"].ToString();
               gx.BRANCH_NAME = dr["BRANCH_NAME"].ToString();
               gx.DESCRIPTION = dr["DESCRIPTION"].ToString();
               gx.BRANCH_PHONE = dr["BRANCH_PHONE"].ToString();
               gx.ADDRESS = dr["ADDRESS"].ToString();
               gx.CITY_ID = int.Parse(dr["CITY_ID"].ToString());
               gx.COMPANY_ID = int.Parse(dr["COMPANY_ID"].ToString()); 
           }
           return gx;
       }
       public Distances loadDistance(int val)
       {
           Distances gx = new Distances();
           tb = ex.loadDistance(val);
           foreach (DataRow dr in tb.Rows)
           {
               gx.BRANCH_ID_FROM = int.Parse( dr["BRANCH_ID_FROM"].ToString());
               gx.BRANCH_ID_TO = int.Parse( dr["BRANCH_ID_TO"].ToString());
               gx.KM = float.Parse( dr["KM"].ToString());
           }
           return gx;
       }
       public C_Services loadService(int val)
       {
           C_Services gx = new C_Services();
           tb = ex.loadService(val);
           foreach (DataRow dr in tb.Rows)
           {
               gx.SERVICE_CODE = dr["SERVICE_CODE"].ToString();
               gx.SERVICE_NAME = dr["SERVICE_NAME"].ToString();
               gx.DESCRIPTION = dr["DESCRIPTION"].ToString();
           }
           return gx;
       }
       public C_News loadNews(int val)
       {
           C_News gx = new C_News();
           tb = ex.loadNews(val);
           foreach (DataRow dr in tb.Rows)
           {
               gx.TITLE = dr["TITLE"].ToString();
               gx.SUBJECT = dr["SUBJECT"].ToString();
               gx.BODY = dr["BODY"].ToString();
               gx.STATUS = bool.Parse( dr["STATUS"].ToString());
           }
           return gx;
       }
       public Delivery_free_polices loadFeePolicy(int val)
       {
           Delivery_free_polices gx = new Delivery_free_polices();
           tb = ex.loadFeePolicy(val);
           int tam = tb.Rows.Count;
           foreach (DataRow dr in tb.Rows)
           {
               gx.SERVICE_ID = int.Parse( dr["SERVICE_ID"].ToString());
               gx.DISTANCE_FROM =float.Parse( dr["DISTANCE_FROM"].ToString());
               gx.DISTANCE_TO =float.Parse( dr["DISTANCE_TO"].ToString());
               gx.FEE_PER_KM =float.Parse( dr["FEE_PER_KM"].ToString());
               gx.WEIGHT_FROM =float.Parse( dr["WEIGHT_FROM"].ToString());
               gx.WEIGHT_TO =float.Parse( dr["WEIGHT_TO"].ToString());
               gx.FEE_PER_KG =float.Parse( dr["FEE_PER_KG"].ToString());
           }
           return gx;
       }
       public DataTable loadBranchCity(int val)
       {
           
          return tb = ex.loadBranchCity(val);
          
       }
       public DataTable loadEmploy(int val)
       {

           return tb = ex.loadEmploy(val);

       }
       public DataTable loadsearchOder(int a, int b, String c, int d, String e, String f, int r)
       {

           return tb = ex.SearchOder(a, b, c, d, e, f, r);

       }
    }
}
